package unilearn.facade;

import java.sql.SQLException;

import unilearn.da.DASubmission;
import unilearn.domain.Assessment;
import unilearn.domain.Assignment;
import unilearn.domain.DataFile;
import unilearn.domain.Submission;

/**
 * @author Ben Morall, 4158768
 * @version 0.1, 25 April 2008, inital creation, blm
 */
public class SubmissionFacade
{

	public static Submission createNewSubmission(Assignment assignment, DataFile file,
			String studentNumber) throws SQLException
	{
		long assignmentID = assignment.getAssignmentID();
		long fileID = file.getFileID();

		return DASubmission.createNewSubmission(assignmentID, studentNumber, fileID);
	}

	public static boolean deleteSubmission(Submission submission) throws SQLException
	{
		long submissionID = submission.getSubmissionID();

		return DASubmission.deleteSubmission(submissionID);
	}

	public static Submission getSubmission(long submissionID) throws SQLException
	{
		return DASubmission.getSubmission(submissionID);
	}

	public static Submission getSubmission(Assessment assessment) throws SQLException
	{
		long assessmentID = assessment.getAssessmentID();

		return DASubmission.getSubmission(assessmentID);
	}

	public static Submission[] getAssignmentSubmissions(long assignmentID)
		throws SQLException
	{
		return DASubmission.getAssignmentSubmissions(assignmentID);
	}

	public static Submission[] getSubmissions(Assignment assignment) throws SQLException
	{
		long assignmentID = assignment.getAssignmentID();

		return getAssignmentSubmissions(assignmentID);
	}

	public static Submission[] getSubmissions(String studentNumber) throws SQLException
	{
		return DASubmission.getStudentSubmissions(studentNumber);
	}

	public static String[] getStudentNumbers() throws SQLException
	{
		return DASubmission.getStudentNumberss();
	}

	public static void updateSubmission(Submission submission, DataFile file)
		throws SQLException
	{
		long submissionID = submission.getSubmissionID();
		long fileID = file.getFileID();

		DASubmission.updateSubmission(submissionID, fileID);
		submission.setFileID(fileID);
	}
}
